package com.lagou.mapper;

import com.lagou.domain.Orders;
import com.lagou.domain.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.tools.ant.taskdefs.condition.Or;

import java.util.List;

public interface OrderAnno {

	@Select("select * from orders")
	@Results({
		@Result(property = "id",column = "id",id = true),
		@Result(property = "orderTime",column = "ordertime"),
		@Result(property = "total",column = "total"),
		@Result(property = "uid",column = "uid"),
		@Result(property = "user",javaType = User.class,column = "uid", one = @One(select = "com.lagou.mapper.UserAnno.selectById") )
	})
	public List<Orders> findOrders();

	@Select("select * from orders where uid = #{uid}")
	public List<Orders> findOrdersByUserId(Integer uid);
}
